WebJavascript

Le script d'avril
<BODY>
<SCRIPT>

var mykey;

if (window.Event){
document.captureEvents(Event.KEYDOWN);
}

document.onkeydown = myKeyDown;

function myKeyDown(e){

if (window.Event){
mykey = e.which;
}
else{
mykey = event.keyCode
}

mykey = String.fromCharCode(mykey);

if ((mykey == "n") || (mykey == "N")){
document.location.href = "http://www.netmag.co.uk";}
if ((mykey == "m") || (mykey == "M")){
document.location.href = "http://www.macformat.co.uk";}

}

</SCRIPT>

<A HREF="http://www.netmag.co.uk" STYLE="color: #000000;" >N</A>
<A HREF="http://www.netmag.co.uk" STYLE="color: #000000; text-decoration: none" >etmag</A>
<BR>
<A HREF="http://www.macformat.co.uk" STYLE="color: #000000;" >M</A>
<A HREF="http://www.macformat.co.uk" STYLE="color: #000000; text-decoration: none">acformat</A>

</BODY>
</HTML>

Vos sites en questions

Format de saisie

function testdate(d)
{
   test=true;
   for (i=0;i<d.length;i++)
   {
      switch (i)
      {
         case 0 : if (d.substr(0,1) <0 || d.substr(0,1) >3 || isNaN(d.substr(0,1)) ) test=false; break
         case 1 : if (d.substr(0,2) <1 || d.substr(0,2) >31 || isNaN(d.substr(0,2)) ) test=false; break
         case 2 : if (d.substr(2,1) != "\/" ) test=false; break
         case 3 : if (d.substr(3,1) <0 || d.substr(3,1) >1 || isNaN(d.substr(3,1)) ) test=false; break
         case 4 : if (d.substr(3,2) <1 || d.substr(3,2) >12 || isNaN(d.substr(3,2)) ) test=false; break
         case 5 : if (d.substr(5,1) != "\/" ) test=false; break
         case 6 : if ( isNaN(d.substr(6,1)) ) test=false; break
         case 7 : if ( isNaN(d.substr(7,1)) ) test=false; break
      }
   }
   if (!test) 
      frm.date.value=d.substr(0,(d.length-1));
}

Et l'appel de la fonction dans un formulaire :

<input type="texte" name="date" size="6" maxlength=8 onKeyUp="testdate(this.value)">

Plusieurs listes

<form name=f>
<select name="liste1">
<option value="page1.htm"> Première page
<option value="page2.htm"> Deuxième page
<option value="page3.htm"> Troisième page
<br>
<input type="button" value="Hop" onClick="location.href=f.liste1.options[f.liste1.selectedIndex].value">
<br><br>
<select name="liste2">
<option value="page4.htm"> Quatrième page
<option value="page5.htm"> Cinquième page
<option value="page6.htm"> Sixième page
<br>
<input type="button" value="Hop" onClick="location.href=f.liste2.options[f.liste2.selectedIndex].value">
</form>

Liste bien formatée

<?php
  echo sprintf('%-15s',$chaine);
?>

Le texte sera alors aligné à gauche. Mais si vous le voulez à droite, il suffit d'enlever le signe "moins" : 

<?php
  echo sprintf('%15s',$chaine);
?>

De la couleur

<style>
BODY      
{ 	
	background-color : #A58801;
	scrollbar-face-color: #A1A5FF; 
	scrollbar-shadow-color: #000000; 
	scrollbar-highlight-color: #FFFFFF; 
	scrollbar-3dlight-color: #000000; 
	scrollbar-darkshadow-color: #000000; 
	scrollbar-track-color: #457820; 
}
</style>

C'est l'heure de déjeuner

<script type="text/javascript">
heure=(new Date()).getHours();
if (heure>0 && heure<7)
{
	document.bgColor="#000000";
	document.write('<font face="Arial" size=4 color="#FFFFFF">Bonne nuit ! Bienvenue sur mon site</font><br>');
	document.write('<img src="nuit.jpg">');
}
else if (heure<12)
{
	document.bgColor="#FFFFFF";
	document.write('<font face="Arial" size=4 color="#000000">Bonjour ! Bienvenue sur mon site</font><br>');
	document.write('<img src="jour.jpg">');
}
else
{
	document.bgColor="#A0A0A0";
	document.write('<font face="Arial" size=4 color="#EFEFEF">Bonsoir ! Bienvenue sur mon site</font><br>');
	document.write('<img src="soir.jpg">');	
}
</script>

Initiation au XML (2/3)

mobiles.xml

(un seul enregistrement reproduit)

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="mobiles.xsl"?>
<!DOCTYPE PHONES SYSTEM "mobiles.dtd">
<PHONES>
<PRODUCT>
<PRODNAME>Nokia 3210</PRODNAME>
<BATTERY>
<STANDBY>120</STANDBY>
<TALKTIME>180</TALKTIME>
<CHARGE>240</CHARGE>
</BATTERY>
<FEATURE>
<NAME>Dual Band</NAME>
<VALUE>Yes</VALUE>
</FEATURE>
<WEIGHT>151g</WEIGHT>
<PICTURE>nok3210.jpg</PICTURE>
</PRODUCT>
</PHONES>

mobiles.xsl eXtensible Style Sheet

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>Phone</TITLE>
</HEAD>

<BODY BGCOLOR="#000000">
<TABLE ALIGN="CENTER" BGCOLOR="#FFFFFF" WIDTH="600">
<FONT SIZE="-2">
<xsl:apply-templates select="PHONES/PRODUCT" />
</FONT>
</TABLE>
</BODY>
</HTML>
</xsl:template>

<xsl:template match="PHONES/PRODUCT">
<TR>
<TD WIDTH="150" ALIGN="CENTER">
<IMG>
<xsl:attribute name="src">
<xsl:value-of select="PICTURE"/>
</xsl:attribute>
</IMG>
</TD>

<TD WIDTH="450" ALIGN="LEFT" VALIGN="TOP">
<DIV STYLE="font-family:arial,helvetica; font-size:14pt; color:blue">
<xsl:value-of select="PRODNAME"/>
</DIV>

<DIV STYLE="font-family:arial,helvetica; font-size:8pt; color:darkblue">
<B>Battery</B>
</DIV>

<DIV STYLE="text-ident:1em;font-family:arial,helvetica; font-size:8pt;">
<B>Standby:</B> <xsl:value-of select="BATTERY/STANDBY"/>Hours
<B>Talktime:</B> <xsl:value-of select="BATTERY/TALKTIME"/>Mins
<B>Charging:</B> <xsl:value-of select="BATTERY/CHARGE"/>Mins
</DIV>

<DIV STYLE="font-family:arial,helvetica; font-size:8pt; color:darkblue">
<B>Features</B>
</DIV>

<DIV STYLE="text-ident:2em;font-family:arial,helvetica; font-size:8pt;">
<xsl:for-each select="FEATURE">
<DIV>
<B> <xsl:value-of select="NAME"/> </B>
<xsl:value-of select="VALUE"/>
</DIV>
</xsl:for-each>
</DIV>

<DIV STYLE="font-family:arial,helvetica; font-size:8pt; color:black;">
<B>Weight:</B> <xsl:value-of select="WEIGHT"/>
</DIV>
</TD>
</TR>
</xsl:template>

</xsl:stylesheet>

mobiles.dtd Document Data Definition File
<!ELEMENT PHONES (PRODUCT)+>
<!ELEMENT PRODUCT (PRODNAME,BATTERY,FEATURE*,WEIGHT,PICTURE)>
<!ELEMENT PRODNAME (#PCDATA)>
<!ELEMENT BATTERY (STANDBY?,TALKTIME?,CHARGE?)>
<!ELEMENT STANDBY (#PCDATA)>
<!ELEMENT TALKTIME (#PCDATA)>
<!ELEMENT CHARGE (#PCDATA)>
<!ELEMENT FEATURE (NAME,VALUE?)>
<!ELEMENT NAME (#PCDATA)>
<!ELEMENT VALUE (#PCDATA)>
<!ELEMENT WEIGHT (#PCDATA)>
<!ELEMENT PICTURE (#PCDATA)>